package com.cml.common.serializable;

import com.cml.common.dto.message.FetchAllServerListReponse;
import com.cml.common.dto.entity.Message;
import com.cml.common.util.SocketChannelParseStringUtil;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;

/**
 * 姓名：陈茂林
 * 时间：2023/10/23 14:08
 * 描述：
 */
public class FetchAllServerListReponseSerializable extends MessageSerializable {
    public void doBuildEncoderMessage(Message message, ByteBuffer byteBuffer) {
        FetchAllServerListReponse fetchAllServerListReponse = (FetchAllServerListReponse) message;
        SocketChannelParseStringUtil.stringDataBuild(byteBuffer,fetchAllServerListReponse.getAllServerList());
    }

    public Message doBuildDecoderMessage(SocketChannel socketChannel) throws IOException {
        FetchAllServerListReponse fetchAllServerListReponse =new FetchAllServerListReponse();

        fetchAllServerListReponse.setAllServerList(SocketChannelParseStringUtil.parse(socketChannel));
        return fetchAllServerListReponse;
    }
}
